<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>试卷管理</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="container">
    <h1 class="mt-5">试卷管理</h1>

    <!-- 导航菜单 -->
    <div class="mt-4 mb-4">
        <ul class="nav nav-pills">
            <li class="nav-item">
                <a class="nav-link" href="${pageContext.request.contextPath}/teacher/home">首页</a>
            </li>
            <li class="nav-item">
                <a class="nav-link active" href="#">试卷管理</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="${pageContext.request.contextPath}/teacher/questionBank">题库管理</a>
            </li>
        </ul>
    </div>

    <!-- 创建试卷表单 -->
    <div class="card mt-4">
        <div class="card-header">
            <h3>创建新试卷</h3>
        </div>
        <div class="card-body">
            <form id="createExamForm">
                <div class="mb-3">
                    <label for="examTitle" class="form-label">试卷标题</label>
                    <input type="text" class="form-control" id="examTitle" name="examTitle" required>
                </div>
                <div class="mb-3">
                    <label for="examTotalScore" class="form-label">总分</label>
                    <input type="number" class="form-control" id="examTotalScore" name="examTotalScore" disabled>  <!-- 禁用输入框 -->
                </div>
                <div class="mb-3">
                    <label for="questionCount" class="form-label">试题数量</label>
                    <input type="number" class="form-control" id="questionCount" value="1" name="questionCount" required onblur="calculateTotalScore()">  <!-- 失去焦点时触发计算 -->
                </div>
                <div class="mb-3">
                    <label for="questionValue" class="form-label">每题分值</label>
                    <input type="number" class="form-control" id="questionValue" value="1" name="questionValue" required onblur="calculateTotalScore()">  <!-- 失去焦点时触发计算 -->
                </div>
                <button type="submit" class="btn btn-primary">创建试卷</button>
            </form>
        </div>
    </div>

    <!-- 试卷列表 -->
    <div class="card mt-4">
        <div class="card-header">
            <h3>现有试卷</h3>
        </div>
        <div class="card-body">
            <table class="table table-striped" id="examTable">
                <thead>
                <tr>
                    <th>试卷号</th>
                    <th>试卷标题</th>
                    <th>试题数量</th>
                    <th>每题分值</th>
                    <th>创建时间</th>
                    <th>试卷状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <!-- 动态加载试卷数据 -->
                </tbody>
            </table>
        </div>
    </div>


    <!-- 试卷详情模态框 -->
    <div class="modal fade" id="examDetailModal" tabindex="-1" aria-labelledby="examDetailModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="examDetailModalLabel">试卷详情</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <!-- 试卷信息展示 -->
                    <div class="mb-4">
                        <h3 id="examTitleDetail" class="text-center"></h3>
                        <p class="text-center" id="examCreator"></p>
                        <p class="text-center" id="totalScoreOfExam"></p>
                    </div>

                    <hr>

                    <div id="examQuestionsList"></div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>


    <!-- 学生成绩模态框 -->
    <div class="modal fade" id="studentScoreModal" tabindex="-1" aria-labelledby="studentScoreModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="studentScoreModalLabel">参加该试卷的学生成绩</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>学生姓名</th>
                            <th>学号</th>
                            <th>专业</th>
                            <th>成绩</th>
                            <th>提交时间</th>
                            <th>操作</th> <!-- 新增操作栏 -->
                        </tr>
                        </thead>
                        <tbody id="studentScoreList">
                        <!-- 学生成绩列表会填充到这里 -->
                        </tbody>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="solutionModal" tabindex="-1" aria-labelledby="solutionModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title text-center w-100" id="solutionModalLabel">试题解析</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div class="text-center mb-4">
                        <h3><span id="examTitle1"></span></h3>
                        <h5>
                            出卷人：<span id="teacherName"></span>
                            <span class="mx-3"></span> <!-- 添加一个空的span，设置水平间距 -->
                            学生得分：<span id="totalScore"></span>
                        </h5>

                    </div>
                    <!-- 介绍性文字 -->
                    <p class="mt-3">备注：本卷为单选题，每题 <span id="scorePerQuestion"></span> 分</p>
                    <!-- 问题列表 -->
                    <div id="questionsList"></div>
                </div>
            </div>
        </div>
    </div>


</div>

<script src="${pageContext.request.contextPath}/static/js/teacher/examManage.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
